package com.house.house.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.house.house.dao.HouseRepository;
import com.house.house.dao.OwnerRepository;
import com.house.house.entity.House;
import com.house.house.entity.Owner;
import com.house.house.util.enums.Sex;

@Service
@Transactional
public class OwnerService implements IOwnerService {
	@Autowired
	private OwnerRepository ownerRepository;
	private HouseRepository houseRepository;
	
	@Override
	public void save() {
		Owner owner = new Owner();
		owner.setOwnerName("kevin");
		owner.setSex(Sex.male);
		owner.setIdCard("123456789456123456");
		owner.setEmail("12345@qq.com");
		owner.setOwnerPhone("12345678901");
		ownerRepository.save(owner);
	}
	
	public void saveOrUpdate(Owner owner) {
	  
		ownerRepository.save(owner);
	}
	@Transactional(readOnly = true)
	public Owner findOne(Long id) {
		Owner owner = ownerRepository.findOne(id);
		return owner;
	}
	
	

}
